package com.tianji.remark.task;

import com.tianji.remark.service.ILikedRecordService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class LikedTimesCheckTask {

    private final static List<String> BIZ_TYPE = List.of("QA","NOTE");
    private static final int MAX_BIZ_SIZE = 30;

    @Autowired
    private ILikedRecordService likedRecordService;

    /**
     *  延时任务每20秒执行一次，将业务对应的点赞次数通知到业务方
     */
    @Scheduled(fixedDelay = 20000)
    public void checkLikedTimes(){
        for (String s : BIZ_TYPE) {
            likedRecordService.readLikedTimesAndSendMessage(s,MAX_BIZ_SIZE);
        }
    }

}
